<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>04-金星地球运行轨迹</title>
    <style>
        canvas{
            border: 1px solid #000;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="800" height="600"></canvas>
    <script>
        var canvas = document.getElementById("canvas")
        var ctx = canvas.getContext("2d")
        console.log(ctx)
        var a = 1
        var off0 = -Math.PI/2
        var off1 = -Math.PI/2
//        ctx.moveTo(200,200)
        ctx.arc(300,300,200,2*Math.PI,0)
        ctx.fill()
        ctx.beginPath()
        ctx.arc(300,300,170,2*Math.PI,0)
        ctx.fill()
        // 以上是两个圆
        setInterval(function () {
            ctx.beginPath()
            ctx.moveTo(300.5+200*Math.cos(off0),300.5+200*Math.sin(off0))
            ctx.lineTo(300.5+170*Math.cos(off1),300.5+170*Math.sin(off1))
            ctx.stroke()
            ctx.strokeStyle = "#fff"
            off0 += Math.PI/50
            off1 += Math.PI/110 // 改这一行的数字就好了
        },100)
    </script>
</body>
</html>